<?php
$task = $game->rw_get_sys($arr_data->rwid);
$player = $game->player_get_uinfo();
$ptask = $game->rw_player_get_info($arr_data->rwid);

$数组_任务道具ID数量 = explode(',',$task->rwdj);
$数组_任务药品ID数量 = explode(',',$task->rwyp);
$数组_任务装备ID = explode(',',$task->rwyp);


$jldjidarr = array();
$jldjslarr = array();
$jlypidarr = array();
$jlypslarr = array();
$jlzbslarr = array();

$链接_接受任务 = "";
$链接_提交任务 = "";
$链接_奖励道具 = "";
$链接_奖励药品 = "";
$链接_奖励装备 = "";

$任务_奖励经验 = $task->rwexp;
$任务_奖励游戏币 = $task->rwyxb;
$任务_任务提示 = '';

if ($ptask){
    if ($ptask->rwzt == 3){
        echo "{$变量_系统->链接_返回游戏}";
        exit();
    }
}

if ($task->rwdj != '' ){
    for ($i=0;$i<count($数组_任务道具ID数量);$i++){
        $djarr = explode('|',$数组_任务道具ID数量[$i]);
        $djid = $djarr[0];
        $djcount = $djarr[1];
        array_push($jldjidarr,$djid);
        array_push($jldjslarr,$djcount);

        $任务道具 = $game->dj_get_sys($djid);
        $奖励道具 = $game->create_url("cmd=djinfo&djid={$任务道具->djid}" , $任务道具->djname);
        $链接_奖励道具 .="<div class='djys'>{$奖励道具}x{$djcount}</div>";
    }
}

if ($task->rwyp != ''){
    for ($i = 0; $i<count($数组_任务药品ID数量); $i++){
        $yparr = explode('|', $数组_任务药品ID数量[$i]);
        $ypid = $yparr[0];
        $ypcount = $yparr[1];
        array_push($jlypidarr,$ypid);
        array_push($jlypslarr,$ypcount);
        $任务药品 = $game->yp_get_info_sys($ypid);
        $奖励药品 = $game->create_url("cmd=ypinfo&ypid={$任务药品->ypid}",$任务药品->ypname);
        $链接_奖励药品 .="<div class='ypys'>{$奖励药品}x{$djcount}</div>";

    }
}

if ($task->rwzb != ''){
    for ( $i = 0 ; $i < count($数组_任务装备ID) ; $i++){
        $zbname = $ret[$i]->zbname;
        array_push($jlzbslarr,$数组_任务装备ID[$i]);
        $任务装备 = $game->zb_get_info_sys($数组_任务装备ID[$i]);
        $奖励装备 = $game->create_url("cmd=zbinfo_sys&zbid={$任务装备->zbid}",$任务装备->zbname);
        $链接_奖励装备 .="<div class='zbys'>{$奖励装备}x{$djcount}</div>";

    }
}






if (isset($arr_data->canshu)){
    switch ($arr_data->canshu){
        case 'jieshou':
            if ($ptask){
                $tishi = '请不要重复接取任务';
                break;
            }
            $day = 0;
            if ($task->rwlx == 2){
                $day = date('d');
            }
            $ret = $game->rw_insert_player_rwid($arr_data->rwid);
            if ($ret){
                $tishi = '接受成功';
                if ($task->rwzl == 1){
                    $daoju = $game->dj_get_player( $task->rwyq );
                    if ($daoju){
                        $game->rw_update_dj($task->rwyq , $daoju->djsum);

                    }

                }
            }


            break;
        case 'tijiao':
            if ($ptask->rwzt == 2){
                $bool = $game->rw_com($arr_data->rwid);
                if ($bool){

                    $game->player_add_exp($task->rwexp);
                    $game->yxb_change(1,$task->rwyxb);
                    for ($i=0; $i<count($jldjidarr); $i++){
                        $game->dj_add($jldjidarr[$i],$jldjslarr[$i]);
                    }
                    for ($i=0;$i<count($jlypidarr);$i++){
                        $game->yp_add($jlypidarr[$i],$jlypslarr[$i]);
                    }

                    foreach ($jlzbslarr as $jlzbid){
                        $game->zb_add_zhuangbei($jlzbid);
                    }
                    echo "任务完成,获得：<br/>$rwjlhtml{$变量_系统->链接_返回游戏_按钮短}";
                    exit();
                }

            }
            break;

    }
}

$game->rw_update_rwzt();

switch ($task->rwzl){
    case 1://收集

        $rwyq = $game->dj_get_sys($task->rwyq);
        $任务_任务要求 ="收集($task->rwcount)$rwyq->djname";
        break;
    case 2://打怪

        $guaiwu = $game->gw_get_info_sys($task->rwyq);
        $gwmap = $game->gw_get_mid($guaiwu->id );
        $pvemap = '';
        foreach ($gwmap as $map){
            $qy = $game->mid_get_qy($map->mqy );
            $pvemap .= "[$qy->qyname -> $map->mname]";
        }
        $任务_任务要求 ="击杀{$task->rwcount}{$guaiwu->gname}<br/>{$pvemap}";

        break;

}
$cfnpc = $game->npc_get_info($task->chufa);
$tjnpc = $game->npc_get_info($task->tijiao);
$任务_任务要求 .="触发：{$cfnpc->nname}<br/>提交：{$tjnpc->nname}";

$ptask = $game->rw_player_get_info($arr_data->rwid);
$任务_任务进度 = '';

if ($ptask){
    if ($ptask->tijiao == $arr_data->nid){
        $任务_任务进度 = "$ptask->rwnowcount/$ptask->rwcount";
        $链接_提交任务 = $game->create_url("cmd=task&nid={$arr_data->nid}&canshu=tijiao&rwid={$arr_data->rwid}","提交任务");
    }

}else{
    if ($task->chufa == $arr_data->nid){
        $链接_接受任务 = $game->create_url("cmd=task&nid={$arr_data->nid}&canshu=jieshou&rwid={$arr_data->rwid}", "接受任务");

    }

}

$taskhtml = "
【{$task->rwname}】:<br/>
{$task->rwinfo}<br/>
经验:{$任务_奖励经验}<br/>
游戏币:{$任务_奖励游戏币}<br/>
{$任务_任务要求}<br/>
{$链接_奖励装备}
{$链接_奖励道具}
{$链接_奖励药品}
{$任务_任务提示}<br/>
任务进度:{$任务_任务进度}<br/>
{$链接_接受任务}{$链接_提交任务}<br/>
{$变量_系统->链接_返回游戏}
";
echo $taskhtml;
?>